﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FunDraw.LayerInfos;

namespace FunDraw
{
    public partial class DlgNewLayer : Form
    {
        public LAYERTYPE LayerType = LAYERTYPE.LINE;
        public string LayerName = "";

        public DlgNewLayer()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 窗口展示事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DlgNewLayer_Shown(object sender, EventArgs e)
        {
            // 初始化图层列表combbox
            cbb_layertype.Items.Clear();
            foreach(string name in Enum.GetNames(typeof(LAYERTYPE)))
            {
                cbb_layertype.Items.Add(name);
            }
            cbb_layertype.SelectedIndex = 0;

            //初始化图层名称文本框
            txt_layername.Text = "";
        }

        /// <summary>
        /// 确认按钮的点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ok_Click(object sender, EventArgs e)
        {
            string typename = cbb_layertype.Text;
            LayerType = (LAYERTYPE)Enum.Parse(typeof(LAYERTYPE), typename);
            LayerName = txt_layername.Text;
            this.DialogResult = DialogResult.OK;
        }

        /// <summary>
        /// 取消添加新的图层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}
